package com.example.tianyidemo.service.impl;
import com.example.tianyidemo.Mapper.PostMapper;
import com.example.tianyidemo.pojo.*;
import com.example.tianyidemo.service.PostService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class Postimpl implements PostService {
    private static final Logger logger = LoggerFactory.getLogger(Postimpl.class);
    //  service不能操作数据库，调用mapper接口
    @Autowired
    private PostMapper Postmapper;
    @Override
    public List<Post> getpost() {
        List<Post> postList = Postmapper.getPost();
        // 填充每个Section的circles属性
        for (Post post : postList) {
            List<User> user = Postmapper.getPostId(post.getPostUserID());
            post.setUser(user);  // 修改方法名以匹配属性名
        }
        for (Post post : postList) {
            List<Comment> comment = Postmapper.getComment(post.getPostCommentID());
            post.setComment(comment);  // 修改方法名以匹配属性名
        }
        return postList;
    }
}
